package com.partition.mysql.em;

import java.util.Locale;

/**
 * 分区策略
 *
 * @author hexinglin
 * @created 2022-04-08 16:11
 **/
public enum RangeStrategyEnum {
    /*
    * 按天分区
    */
    DAY("day","天"),
    /*
     * 按月分区
     */
    MONTH("month","月"),
    /*
     * 按年分区
     */
    YEAR("year","年"),
    ;

    RangeStrategyEnum(String code, String describe) {
        this.code = code;
        this.describe = describe;
    }

    private String code;
    private String describe;

    /*
    *根据code获取枚举
    */
    public static RangeStrategyEnum getByCode(String code) {

        for (RangeStrategyEnum re : RangeStrategyEnum.values()) {
            if (re.getCode().equals(code.toLowerCase(Locale.ENGLISH))) {
                return re;
            }
        }

        return MONTH;
    }

    public String getCode() {
        return code;
    }

    public String getDescribe() {
        return describe;
    }
}
